<?php
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Europe/Warsaw');
set_include_path('.' . PATH_SEPARATOR . './vendors'
   . PATH_SEPARATOR . './application/blog/models/'
   . PATH_SEPARATOR . './application/models/'
   . PATH_SEPARATOR . './classes/'
   . PATH_SEPARATOR . get_include_path());


require_once("Doctrine/Doctrine.php");
include "Zend/Loader.php";

function myautoload($class_name) {
	//echo $class_name.'-';
	if (file_exists('classes/'.$class_name.'.php')) require_once 'classes/'.$class_name . '.php';
	if (file_exists('classes/blog/models/'.$class_name.'.php')) require_once 'classes/blog/models/'.$class_name . '.php';
	if (file_exists('classes/blog/dao/'.$class_name.'.php')) require_once 'classes/blog/dao/'.$class_name . '.php';
}

spl_autoload_register('myautoload');
spl_autoload_register(array('Doctrine', 'autoload'));
Zend_Loader::registerAutoload();

// load configuration
$config = new Zend_Config_Ini('./application/config.ini', 'general');
$registry = Zend_Registry::getInstance();
$registry->set('config', $config); 

// setup database 
$db = Zend_Db::factory(	$config->db->adapter,
$config->db->config->toArray() );
Zend_Db_Table::setDefaultAdapter($db);

// setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setBaseUrl("/"); 

$frontController->setControllerDirectory(array(
      'default' => './application/blog/controllers',
      'blog'    => './application/blog/controllers',
      'admin3'    => './application/admin/controllers'
));

//$frontController->setControllerDirectory('./application/controllers');

// run!
$frontController->dispatch();